﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %>

<script type="text/javascript" language="javascript" src="../../Scripts/ajaxfileupload.js"></script>

<link href="../../Scripts/jqueryui-1.8.21/css/redmond/jquery-ui-1.8.23.custom.css"
    rel="stylesheet" type="text/css" />

<script type="text/javascript">

    $(function() {
        $("#div_usersetting #tabs").tabs({
            ajaxOptions: {
                error: function(xhr, status, index, anchor) {
                    $(anchor.hash).html(
						"加载内容页失败");
                }
            }
        });
    });
    function submit() {
        //        var mail_account = $("#mail_account").val();
        //        if (mail_account == "") {
        //            alert("账户名不能为空");
        //            return false;
        //        }
        //        $.ajax({
        //            type: "POST",
        //            url: "/Home/DoUpdateUserInfo",
        //            data: { "mailAccount": mail_account },
        //            success: function(data) {
        //                alert(data);
        //            }
        //        });
        return true;
    }


    function proRes(ajaxContext) {
        var restag = {};
        try {
            restag = ajaxContext.get_response().get_object();
        } catch (e) {
            alert("程序出现错误，请联系管理员");
            return;  // return if result is not json
        }
        if (restag.res != true) {
            alert(restag.msg);
        }
        else {
            alert("操作成功");
            $.fn.deltab('usersetting');
        }
    }

    //绑定input=file 实现图片预览 
    function PreviewImage(imgFile) {
        var filextension = imgFile.value.substring(imgFile.value.lastIndexOf("."), imgFile.value.length);
        filextension = filextension.toLowerCase();
        if ((filextension != '.jpg') && (filextension != '.gif') && (filextension != '.jpeg') && (filextension != '.png') && (filextension != '.bmp')) {
            alert("对不起，系统仅支持标准格式的照片，请您调整格式后重新上传，谢谢 !");
            imgFile.focus();
        }
        else {
            var path;
            if (document.all)//IE
            {
                imgFile.select();
                path = document.selection.createRange().text;
                document.getElementById("localImag").innerHTML = "";
                document.getElementById("localImag").style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled='true',sizingMethod='scale',src=\"" + path + "\")"; //使用滤镜效果   
            }
            else//FF  
            {
                path = window.URL.createObjectURL(imgFile.files[0]);
                document.getElementById("localImag").innerHTML = "<img id='usersetting_img' width='120px' height='100px' src='" + path + "'/>";
                //document.getElementById("img1").src = path;
            }
        }
    }

    //图片异步上传
    function ajaxFileUpload() {
        $.ajaxFileUpload({
            url: "/Home/UploadHeadImg",
            secureuri: false,
            fileElementId: "uploadHeadImg",
            dataType: "json",
            success: function(data, status) {
                if (data == true) {
                    alert("上传成功");
                    $("#menu_usersetting").trigger("click");
                } else {
                    alert(data);
                }
            },
            error: function(data, status, e) {
                alert(e);
            }
        })
        return false;
    }

    $(function() {
        var domain = $("#current_mail_domain").val();
        $("#staff_email_domain option[value=" + domain + "]").attr("selected", true);
    });
</script>

<div id="div_usersetting">
    <div id="tabs">
        <ul>
            <li><a href="#tabs-1">基础信息</a></li>
            <li><a href="/home/ChangePsw">密码配置</a></li>
        </ul>
        <div id="tabs-1">
            <div id="userinfo" style="padding-top: 0px; padding-left: 10px; height: 500px">
                <%using (Ajax.BeginForm("DoUserSetting", "Home", new AjaxOptions { UpdateTargetId = "tmp", OnSuccess = "proRes" }))
                  { %>
                <div>
                    <input type="submit" class="btn_style" value="保存" />
                    <%= Html.Hidden("staff_id", ViewData["staff_id"])%></div>
                <div style="margin-left: 10px; margin-top: 20px; width: 760px; float: left">
                    <%--                    <div style="margin: 10px 0;">
                        <span style="padding-left: 25px;">员工编码:</span>
                        <%= Html.TextBox("staff_code", ViewData["staff_code"], new { @style = "width:200px; margin-left:8px; border:solid 1px #6C92AD; ", @disabled = "disabled" })%></div>
                    <div style="margin: 10px 0;">
                        <span style="padding-left: 25px;">员工名称:</span>
                        <%= Html.TextBox("staff_name", ViewData["staff_name"], new { @style = "width:200px; margin-left:8px; border:solid 1px #6C92AD;", @disabled = "disabled"  })%></div>--%>
                    <div style="height: 50px; width: 350px; float: left;">
                        <span style="padding-left: 25px; display: inline-block; width: 70px;">邮箱:</span>
                        <%= Html.TextBox("staff_email", ViewData["staff_email"], new { @style = "width:130px; border:solid 1px #6C92AD;" })%>
                        <%=Html.DropDownList("staff_email_domain") %>
                        <%=Html.Hidden("current_mail_domain") %>
                    </div>
                    <div style="height: 50px; margin: 0px 0px 0px 20px; width: 350px; float: left;">
                        <span style="padding-left: 25px; display: inline-block; width: 70px;">Q Q:</span>
                        <%= Html.TextBox("staff_qq", ViewData["staff_qq"], new { @style = "width:233px; border:solid 1px #6C92AD;" })%></div>
                    <div style="height: 50px; width: 350px; float: left;">
                        <span style="padding-left: 25px; display: inline-block; width: 70px;">传真:</span>
                        <%= Html.TextBox("staff_fax", ViewData["staff_fax"], new { @style = "width:233px; border:solid 1px #6C92AD;" })%></div>
                    <div style="height: 50px; margin: 0px 0px 0px 20px; width: 350px; float: left;">
                        <span style="padding-left: 25px; display: inline-block; width: 70px;">住宅电话:</span>
                        <%= Html.TextBox("staff_livenum", ViewData["staff_livenum"], new { @style = "width:233px;  border:solid 1px #6C92AD;" })%></div>
                    <div style="height: 50px; width: 350px; float: left;">
                        <span style="padding-left: 25px; display: inline-block; width: 70px;">手机:</span>
                        <%= Html.TextBox("staff_mobile", ViewData["staff_mobile"], new { @style = "width:233px; border:solid 1px #6C92AD;" })%></div>
                    <div style="height: 50px; margin: 0px 0px 0px 20px; width: 350px; float: left;">
                        <span style="padding-left: 25px; display: inline-block; width: 70px;">短号:</span>
                        <%= Html.TextBox("staff_shortnum", ViewData["staff_shortnum"], new { @style = "width:233px;  border:solid 1px #6C92AD;" })%></div>
                    <div style="height: 50px; width: 350px; float: left;">
                        <span style="padding-left: 25px; display: inline-block; width: 70px;">办公电话:</span>
                        <%= Html.TextBox("staff_officenum", ViewData["staff_officenum"], new { @style = "width:233px;  border:solid 1px #6C92AD;" })%></div>
                    <div style="height: 50px; margin: 0px 0px 0px 20px; width: 350px; float: left;">
                        <span style="padding-left: 25px; display: inline-block; width: 70px;">分 机 号:</span>
                        <%= Html.TextBox("staff_fjh", ViewData["staff_fjh"], new { @style = "width:233px; border:solid 1px #6C92AD;" })%></div>
                    <div style="height: 50px; width: 350px; float: left;">
                        <span style="padding-left: 25px; display: inline-block; width: 70px;">办公地址:</span>
                        <%= Html.TextBox("staff_officeaddr", ViewData["staff_officeaddr"], new { @style = "width:233px; border:solid 1px #6C92AD;" })%></div>
                    <div style="height: 50px; margin: 0px 0px 0px 130px; width: 150px; float: left;">
                        <div id="localImag" style="width: 120px; height: 100px;">
                            <img alt="无" id="usersetting_img" width="100" height="100" src="/Basic/GetImage?fileName=<%=ViewData["user_img"] %>" /></div>
                        <input type="file" name="uploadHeadImg" id="uploadHeadImg" onchange="ajaxFileUpload();" />
                        <%--<input type="button" onclick="javascript:$('#uploadHeadImg').click();" class="btn_style"
                            value="上传" />--%>
                        <%--<input type="button" onclick="return ajaxFileUpload();" class="btn_style" value="保存" />--%>
                    </div>
                    <div style="height: 50px; width: 350px; float: left;">
                        <span style="padding-left: 25px; display: inline-block; width: 70px;">现居地址:</span>
                        <%= Html.TextArea("staff_liveaddr", ViewData["staff_liveaddr"] == null ? "" : ViewData["staff_liveaddr"].ToString(),
                            new { @style = "width:230px;  border:solid 1px #6C92AD; resize:none;" })%></div>
                </div>
                <%} %>
            </div>
        </div>
    </div>
</div>
